
//
//  DisModel.m
//  肿瘤
//
//  Created by 无梦生 on 16/9/14.
//  Copyright © 2016年 Sampson. All rights reserved.
//

#import "DisModel.h"
#import "NetWorkTool.h"
#import "NSString+category.h"
#import <SVProgressHUD.h>
@implementation DisModel


+(instancetype)disWithDict:(NSDictionary *)dict
{
    DisModel * model = [[DisModel alloc]init];
    
    [model setValuesForKeysWithDictionary:dict];
    
    return model;
    
}


-(void)disWithUrlstring:(NSString * )urlstring papmr:(NSDictionary * )paprm Success:(void(^)(NSArray <DisModel*> *))successBlock Error:(void(^)())error
{
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlstring parmas:paprm successBloock:^(id responseObject) {
        
        NSMutableArray * muArray = [NSMutableArray array];
        NSArray * array = responseObject[@"data"];
        [array enumerateObjectsUsingBlock:^(NSDictionary*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            DisModel * model = [DisModel disWithDict:obj];
            
            model.pinYin = [model.ci3_name transformToPinyin];
            
            model.nameFirstLetter = [model.ci3_name transformToPinyinFirstLetter];
            
            [muArray addObject:model];
        }];
        
        if (successBlock) {
            
            successBlock(muArray);
        }
        
        
    } failureBlock:^(NSError *error) {
        
        [SVProgressHUD showErrorWithStatus:@"error"];
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
        
        
    }];
}


-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}


@end
